package com.jerry.springcloud.controller;

import com.jerry.springcloud.bean.Category;
import com.jerry.springcloud.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * 卖家类目
 */
@Controller
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    //类目列表
    @GetMapping("/list")
    public List<Category> list() {
        List<Category> categoryList = categoryService.findAll();
        return categoryList;
    }

    //保存/更新
    @PostMapping("/addOrUpdate")
    public Category addOrUpdate(Category category) {
        return categoryService.saveOrUpdate(category);
    }

}
